<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\EduReportSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '投诉消息';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="edu-report-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <!--        --><? //= Html::a('Create Edu Report', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            //'id',
            [
                'label' => '投诉者',
                'attribute' => 'user.nickname',
            ],
            'title',
            //'style',
            //'obj_id',
            //'user_id',
            'reason',
            'create_time:datetime',
            //'status',

            ['class' => 'yii\grid\ActionColumn',
                'header' => '操作',
                'template' => '{view} {update} {delete} {message}',
                'buttons' => [
                    'message' => function ($url, $model, $key) {
                        if ($model->style == 1) {
                            //重新定义url
                            $params = is_array($key) ? $key : ['id' => $model->user_id];
                            $params[0] = $this->context->id . '/message';
                            $url = Url::toRoute($params);

                            $options = [
                                'title' => Yii::t('yii', '发送消息'),
                                'aria-label' => Yii::t('yii', '发送消息'),
                                'data-pajx' => '0',
                            ];
                            return Html::a('<span class="glyphicon glyphicon-send"></span>', $url, $options);

                        } else {
                            return '';
                        }

                    },
                ],
            ],
        ],
    ]); ?>
</div>
